package com.sky.mapper;

//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper extends BaseMapper<Dish> {

    @Select("select count(*) from dish where status != 0 and category_id = #{categoryId}")
    public Integer dishCountByCategoryId(Long categoryId);

    Page<DishVO> getDishPage(DishPageQueryDTO dto);

    //DishServiceImpl
    //ShoppingCartServiceImpl
    @Select("select * from dish where id = #{id}")
    Dish getDishById(Long id);



    @AutoFill(OperationType.INSERT)
    void saveDishWithFlavor(Dish dish);

    //获取所有需要删除的菜品
    List<Dish> getDishByIds(List<Long> ids);

    void deleteByIds(List<Long> ids);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @Select("select * from dish where category_id = #{categoryId} and status = 1")
    List<Dish> getDishByCategoryId(Integer categoryId);

    List<DishVO> getDishVOByCategoryId(Integer categoryId);
}
